home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!sun001
- From: dthornto@aplo266.spd.dsccc.com (Duane Thornton)
- Newsgroups: comp.lang.c
- Subject: Re: gets(rec->num); I don't know what I am doing wrong...
- Date: 09 Feb 1996 18:31:18 GMT
- Organization: none
- Message-ID: <DTHORNTO.96Feb9123118@aplo266.spd.dsccc.com>
- References: <4fempt$mjg@aphex.direct.ca>
- NNTP-Posting-Host: aplo266.spd.dsccc.com
- In-reply-to: etoivane@direct.ca's message of 9 Feb 1996 05:41:17 GMT
-
- Here is a hint, the prototype for gets() is:
-
- char *gets(char *s);
-
- Duane
-
- ---------------------------- Duane Thornton --------------------------------
- Internet: dthornto@spd.dsccc.com Opinions are my own.
- DSC Communications Corporation Addr: MS 153, 1000 Coit Rd, Plano, TX 75075
- ----------------------------------------------------------------------------
- >>>>> On 9 Feb 1996 05:41:17 GMT, etoivane@direct.ca (Ed Toivanen) said:
-
- Ed> I posted the code that I wrote so far. I can't make
- Ed> gets(rec->id); work properly, I get 6 or 7 compilation errors
- Ed> indicating that parameter 1 does not match function prototype.
- Ed> Each gets() call is incorrect! What to do?
- Ed> /*
- Ed> Ed Toivanen
- Ed> Assign2
- Ed> Comp 3425(Wed)
- Ed> Feb 5, 1996
- Ed> */
- Ed> #define NAME_LEN 40
-
- Ed> typedef enum {FALSE, TRUE} bool;
-
- Ed> typedef enum {SCIENCE, ART} PROGRAM;
-
- Ed> typedef struct science_mark {
- Ed> int math, physics, compsci; /* Range: 0..100 */
- Ed> }SCIENCE_MARK;
-
- Ed> typedef struct art_mark {
- Ed> int acting, dancing; /* Range: 0..100 */
- Ed> }ART_MARK;
-
- Ed> typedef union mark {
- Ed> SCIENCE_MARK scientist;
- Ed> ART_MARK artist;
- Ed> }MARK;
-
- Ed> typedef struct student_record{
- Ed> int id; /* Range: 1..99, Unique */
- Ed> char name[NAME_LEN + 1]; /* Non-unique */
- Ed> PROGRAM major;
- Ed> MARK marks;
- Ed> } STUDENT_RECORD;
-
-
- Ed> /*
- Ed> Assign2.c
- Ed> */
-
- Ed> #include<stdio.h>
- Ed> #include"assign2.h"
-
- Ed> bool initList(char*, FILE*);
- Ed> bool addRecord(FILE*, STUDENT_RECORD*);
- Ed> bool deleteRecord(FILE*, STUDENT_RECORD*);
- Ed> bool searchforRecord(FILE*, STUDENT_RECORD*);
- Ed> bool printList(FILE*);
- Ed> bool printRecord(FILE*, STUDENT_RECORD*);
-
- Ed> int main(void){
- Ed> char studentList[8 + 1];
- Ed> FILE * filePtr;
-
- Ed> printf("Enter database file to open\n");
- Ed> while(!gets(studentList))
- Ed> {}
-
- Ed> if(!initList(studentList, filePtr)){
- Ed> return(1);
- Ed> }
-
- Ed> return(0);
- Ed> }
-
- Ed> bool initList(char* list, FILE* fp){
- Ed> if(!(fp = fopen(list, "wb"))){
- Ed> printf("Error opening %s\n", list);
- Ed> fclose(fp);
- Ed> return(FALSE);
- Ed> }
- Ed> else
- Ed> return(TRUE);
- Ed> }
-
- Ed> bool addRecord(FILE* fp, STUDENT_RECORD* rec){
- Ed> printf("Student id\n");
- Ed> gets(rec->id);
-
- Ed> printf("Student's last name first\n");
- Ed> gets(rec->name);
-
- Ed> printf("Major\n");
- Ed> gets(rec->major);
-
- Ed> printf("Grades\n");
- Ed> switch(rec->major){
- Ed> case SCIENCE:
- Ed> printf("Math\n");
- Ed> fprintf(fp, gets(rec->marks.scientist.math));
-
- Ed> printf("Physics\n");
- Ed> fprintf(fp, gets(rec->marks.scientist.physics));
-
- Ed> printf("Compsci\n");
- Ed> fprintf(fp, gets(rec->marks.scientist.compsci));
- Ed> break;
- Ed> case ART:
- Ed> printf("Acting\n");
- Ed> fprintf(fp, gets(rec->marks.artist.acting));
-
- Ed> printf("Dancing\n");
- Ed> fprintf(fp, gets(rec->marks.artist.dancing));
- Ed> break;
- Ed> default :
- Ed> break;
- Ed> }
- Ed> return(TRUE);
- Ed> }/*End addRec*/
-
- --
- Duane x94916
-
- ---------------------------- Duane Thornton --------------------------------
- Internet: dthornto@spd.dsccc.com Opinions are my own.
- DSC Communications Corporation Addr: MS 153, 1000 Coit Rd, Plano, TX 75075
- ----------------------------------------------------------------------------
-